/**
 *
 */
package com.ssyt.examinationsystem.service.impl;

import com.ssyt.examinationsystem.dao.IArrangeInfoDAO;
import com.ssyt.examinationsystem.dao.IStudentInfoDAO;
import com.ssyt.examinationsystem.dao.impl.ArrangeInfoDAOImpl;
import com.ssyt.examinationsystem.dao.impl.StudentInfoDAOImpl;
import com.ssyt.examinationsystem.entity.ArrangeInfo;
import com.ssyt.examinationsystem.service.IArrangeInfoService;

import java.util.List;
import java.util.Map;

/**
 * @author Administrator
 */
public class ArrangeInfoServiceImpl implements IArrangeInfoService {

    IArrangeInfoDAO arrangeDao = new ArrangeInfoDAOImpl();
    IStudentInfoDAO stuDAO = new StudentInfoDAOImpl();

    @Override
    public String startExam(String stuId, String courseId) {
        // 获取学生信息
        Map<String, Object> student = stuDAO.getStuByStuId(stuId);

        // 获取学生班级编号
        String classId = String.valueOf(student.get("stuClass"));
        // 通过班级编号在考试安排表中查询是否有对应记录

        Map<String, Object> arrange = arrangeDao.getArrangeInfoByClassId(classId, courseId);

        return arrange != null && arrange.size() > 0 ? String.valueOf(arrange.get("paperId")) : null;
    }

    @Override
    public List<Map<String, Object>> getArranges() {
        return arrangeDao.getArranges();
    }

    @Override
    public int updateArrange(ArrangeInfo arrange) {
        return arrangeDao.updateArrange(arrange);
    }

    @Override
    public int addArrange(ArrangeInfo arrange) {
        return arrangeDao.addArrange(arrange);
    }

    @Override
    public int deleteArrange(String arrangeId) {
        return arrangeDao.deleteArrange(arrangeId);
    }
}
